Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the ability to configure Jsonb and generate serializers for JAX-RS return types #3553

Closed
wants to merge 20 commits into from

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Aug 17, 2019

Follow up to #3323 (which was closed after I mistakenly deleted the branch).

The PR is now rebased onto the latest master

@FroMage
Copy link
Member

FroMage commented Sep 4, 2019

@geoand can you fix the conflict?

@stuartwdouglas will you have time to review or should we find another reviewer?

@geoand
Copy link
Contributor Author

geoand commented Sep 4, 2019

@FroMage done :)

@FroMage
Copy link
Member

FroMage commented Sep 4, 2019

Thanks

@stuartwdouglas
Copy link
Member

On the face of it I think it looks ok. Do we have any benchmarks on how much it improves performance (both runtime perf an memory usage when you have a lot of return types)?

@geoand
Copy link
Contributor Author

geoand commented Sep 5, 2019

@stuartwdouglas I had done some simple JMH benchmarking with some very simple and very complex types. For the simple ones the performance improvement was very small, for the very complex ones the improvements could go up to 80%.
As for memory usage, unfortunately I haven't tested it. I'll try and set up some scenarios next week.

@geoand
Copy link
Contributor Author

geoand commented Sep 11, 2019

I haven't yet been able to run the JMH and memory tests, hopefully today or tomorrow

@geoand
Copy link
Contributor Author

geoand commented Oct 3, 2019

This needs to be reworked now that we have JSON-B CDI support in master (as a result of #4212)

@aloubyansky aloubyansky added the triage/needs-rebase This PR needs to be rebased first because it has merge conflicts label Oct 9, 2019
@cescoffier
Copy link
Member

Any update on this one?

@geoand
Copy link
Contributor Author

geoand commented Nov 12, 2019

This has been put on hold in order to do more important things

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

@geoand I have a somewhat naive question on this one: shouldn't JSON-B cache the serializers somehow? I'm wondering if we use it correctly.

/cc @aguibert

@geoand
Copy link
Contributor Author

geoand commented Nov 25, 2019

@gsmet as part of this PR I had found a way to get really deep integration of Serializers into JSON-B.
The code was fairly involved and hasn't been moved into our regular serializer handling

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

Yeah sure. But what I'm wondering is: should the JSON-B performances be that bad? If JSON-B is caching the serializers it generates, I find the 80% improvement to be suspicious (not that I doubt your assertions, I'm rather wondering if either JSON-B or we are doing something wrong).

Might be a good idea to have @aguibert 's opinion on this.

@aguibert
Copy link
Member

thanks for looping me in @gsmet. I've had a look at this PR and spoke with Georgios. To summarize:

  1. My main concern with this PR is that it's essentially re-implementing all of the built-in primitive serializers, which is going to be a lot of code to maintain and may cause Quarkus w/ Yasson behavior to diverge from pure Yasson behavior. Also, we would need to start running the JSON-B TCK w/ Quarkus since we'd be adding a significant amount of code that had the ability to impact behavior.
  2. Overriding this much of Yasson behavior would exclude us from natural performance improvements that will happen in Yasson over time. For example (although not directly applicable here) one of my Yasson colleagues is currently working on a new deserialization algorithm that will improve deser perf ~80%.

Currently the most expensive operation Yasson does is parsing class models using reflection. This is only done once when Yasson first touches a given Java model class. However, this class parsing is done lazily so it may impact first-request time.

I think we should start by adding an SPI to Yasson where we can pass in a list of model classes to be eagerly initialized. This way the expensive class parsing code runs at build-time instead of on first-request. I've raised the following issue to track this enhancement in Yasson: eclipse-ee4j/yasson#366

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

That was exactly my line of thought.

@geoand when you did your testing, it was after warmup or did you always regenerate the Yasson metadata?

@geoand
Copy link
Contributor Author

geoand commented Nov 25, 2019

IIRC it was after warmup.

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

@aguibert could you check that we are doing things correctly in Quarkus/RESTEasy and that we correctly cache the JSON-B instance?

@aguibert
Copy link
Member

yea I'll take a look at what we are currently doing. @geoand I assume you were doing a JAX-RS w/ JSONB benchmark scenario?

@geoand
Copy link
Contributor Author

geoand commented Nov 25, 2019

@aguibert I did both a JAX-RS w JSON-B load test and microbenchmarks with just JSON-B

@gsmet
Copy link
Member

gsmet commented Nov 27, 2019

I'm going to close this one for now. I would prefer @aguibert to lead the effort of checking if we are doing things correctly regarding JSON-B and also optimize things in Yasson itself.

We can reopen if we think it's worth it at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/needs-rebase This PR needs to be rebased first because it has merge conflicts triage/wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants